/**
 * 
 */
package com.study.lock.demo;

/**
 * @author Administrator
 * @date 2019年6月11日
 */
public class ThreadTest {

    public static void main(String args[]){
        //final Bank bank=new Bank();
        //final Bank1 bank=new Bank1();
        //final Bank2 bank=new Bank2();
        //final Bank3 bank=new Bank3();
        final Bank4 bank=new Bank4();
                
        Thread tadd=new Thread(new Runnable() {
            
            @Override
            public void run() {
                // TODO Auto-generated method stub
                while(true){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    bank.addMoney(100);
                    bank.lookMoney();
                    System.out.println("\n");
                    
                }
            }
        });
        
        Thread tsub = new Thread(new Runnable() {
            
            @Override
            public void run() {
                // TODO Auto-generated method stub
                while(true){
                    bank.subMoney(100);
                    bank.lookMoney();
                    System.out.println("\n");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }    
                }
            }
        });
        tsub.start();
        
        tadd.start();
    }
}